home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
idioms.lha
/
idioms
/
2smf.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-08
|
567b
|
26 lines
/* Copyright (c) 1992 by AT&T Bell Laboratories. */
/* Advanced C++ Programming Styles and Idioms */
/* James O. Coplien */
/* All rights reserved. */
#include <stdlib.h>
class X {
public:
// ...
void foo() { fooCounter++; /* . . . . */ }
static void printCounts() {
printf("foo called %d times\en", fooCounter);
}
private:
static int fooCounter;
};
int X::fooCounter = 0;
int main() {
// printCounts(); // error (unless there really
// is a global function f())
X::printCounts(); // fine
}